﻿using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Rigidbody2D))]
public class GiroRotatePower : Giro 
{
    public bool constPower;
    public float firstPower = 5;

	void FixedUpdate () 
    {
        base.FixedUpdate();
        RotateGravity(GetAngel());
	}

    void RotateGravity(float angel)
    {
        float gravityPower = constPower ? firstPower : GetAcceleration().magnitude * speed;
        Vector2 direction = GetDirection();
        direction *= gravityPower;
        rigidbody2D.velocity += direction * Time.fixedDeltaTime;
    }
}
